package com.ldaps.test.repo;

import com.ldaps.test.entity.Person;
import org.springframework.ldap.core.AttributesMapper;

import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;

/**
 * @author daxue0929
 * @date 2021/10/11
 */

public class PersonAttributesMapper implements AttributesMapper<Person> {
    @Override
    public Person mapFromAttributes(Attributes attrs) throws NamingException {

        NamingEnumeration<? extends Attribute> all = attrs.getAll();
        Attribute attribute = all.nextElement();


        Person person = new Person();
        person.setCn((String)attrs.get("cn").get());
        return person;
    }
}
